package com.monkey4cloud.study.webfluxdemo001.service.impl;

import com.monkey4cloud.study.webfluxdemo001.dao.MyUserRepository;
import com.monkey4cloud.study.webfluxdemo001.model.MyUser;
import com.monkey4cloud.study.webfluxdemo001.service.MyUserService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;

@Service
@RequiredArgsConstructor
public class MyUserServiceImpl implements MyUserService {

    private final MyUserRepository myUserRepository;

    @Override
    public Flux<MyUser> findAll() {
        return myUserRepository.findAll();
    }

    @Override
    public Mono<MyUser> findByUsername(String username) {
        return myUserRepository.findByUsername(username);
    }

    @Override
    public Mono<MyUser> save(MyUser user) {
        return myUserRepository.save(user);
    }

    @Override
    public Mono<Void> deleteById (Long id) {
        return myUserRepository.deleteById(id);
    }
}
